/**
 * 
 */
package com.doone.telmarket.interceptor;

import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;




import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

/**
 * @author 吴同庆
 * @date 2009-10-16
 * @description
 * @package com.doone.telmarket.interceptor
 */
@Controller
@Scope("prototype")
public class AnonymityInterceptor extends AbstractInterceptor{
	
	private static final long serialVersionUID = 8377450997039808393L;
	
	private final static String USER_ID = "ctUser";
	
	private final static String ANONYMITY_USER = "匿名用户";
	
	Logger log = Logger.getLogger(AnonymityInterceptor.class);

	@Override
	public String intercept(ActionInvocation actionInvocation) throws Exception {
		log.debug("拦截检查用户是否登录");
		Map<String,Object> session = actionInvocation.getInvocationContext().getSession();
		if(session.get(USER_ID) == null)
		{
			log.debug("用户未登录");
			session.put(USER_ID, ANONYMITY_USER);
		}
		return actionInvocation.invoke();
	}
	
	

}
